﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ElegyPlayground
{
    public class Character
    {

        public Vector2 Position;
        public Vector2 Velocity;
        public Vector2 Acceleration;

        public Character(Texture2D graphics)
            : this()
        {
            Graphic = graphics;
        }

        public Texture2D Graphic
        {
            get;
            set;
        }

        public Character()
        {
            Position = new Vector2(0, 0);
            Velocity = new Vector2(0, 0);
            Acceleration = new Vector2(0, 03);
        }

        public void UpdatePosition(double gameTime, int width, int height)
        {
            Velocity += Acceleration;
            // Move the sprite by speed, scaled by elapsed time.
            Position +=
                Velocity * (float)gameTime;

            int MaxX =
                width - Graphic.Width;
            int MinX = 0;
            int MaxY =
                height - Graphic.Height;
            int MinY = 0;

            // Check for bounce.
            if (Position.X > MaxX)
            {
                Velocity.X *= -1;
                Position.X = MaxX;
            }

            else if (Position.X < MinX)
            {
                Velocity.X *= -1;
                Position.X = MinX;
            }

            if (Position.Y > MaxY)
            {
                Velocity.Y = 0;
                Position.Y = MaxY;
            }

            else if (Position.Y < MinY)
            {
                 Velocity.Y *= -1;
                Position.Y = MinY;
            }
        }
    }
}
